/*
 * BaseEventFragment.java
 * business
 *
 * Created by ChenTao on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.base;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.yidiandao.business.data.event.RefreshDataEvent;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 *通知数据刷新Fragment基类
 *
 * <p>里面集成了EventBus
 */
public abstract class BaseEventFragment extends BaseFragment {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EventBus.getDefault().register(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(RefreshDataEvent event) {
        notifyDataChanged();
    }

    public abstract void notifyDataChanged();
}
